<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>提交作业</title>
    <link rel="stylesheet" type="text/css" href="../static/css/common.css"/>
    <link rel="stylesheet" type="text/css" href="../static/css/main.css"/>
    <link rel="stylesheet" type="text/css" href="../static/layui/css/layui.css"/>
    <script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.5.1/jquery.js"></script>
    <style>
        th {
            width: 100px;
            text-align: center;
        }

        td {
            /*width: 100%;*/
            text-align: center;
        }

        #title {
            width: 530px;
        }

        #content {
            width: 530px;
        }

        #date {
            width: 530px;
        }

        .main-wrap {
            margin-left: 0;
        }
    </style>
</head>
<body>

<div class="sidebar-content">
    <div class="main-wrap">
        <div class="result-wrap">
            <div class="result-content">
                <form method="post" id="myform" name="myform " action="" class="layui-form">
                    <table class="insert-tab">
                        <tbody>
                        <tr>
                            <th>任务：</th>
                            <td>
                                <input class="common-text required" id="title" name="" size="50" type="text"
                                       th:value="${task.getTask_name()}">
                            </td>
                            <th>分数：</th>
                            <td>
                                <input th:if="${assignment.getAss_grade() ne '' }" class="common-text required" id="pojo"  name="" size="50" type="text"
                                       style="width: 200px;color: red; " th:value="${assignment.getAss_grade()}">
                                <input th:if="${assignment.getAss_grade() eq '' }" class="common-text required" id="pojo"  name="" size="50" type="text"
                                       style="width: 200px;color: red;">

                            </td>
                        </tr>
                        <tr>
                            <th>作业：</th>
                            <td colspan="3">
								<textarea class="layui-textarea fly-editor" lay-verify="contents"
                                          type="text" name="contents" id="contents"
                                          th:utext="${assignment.getAss_content()}"></textarea>
                            </td>
                            <input type="hidden" id="ass_id" th:value="${assignment.getAss_id()}">
                        </tr>
                        <tr>
                            <th>操作：</th>
                            <td>
                                <input id="submit" class="btn btn-primary btn6 mr10 layui-col-lg-offset4" lay-submit
                                       value="批改完成" type="button" lay-filter="formSubmit">
                            </td>
                        </tr>
                        </tbody>
                    </table>
                </form>
            </div>
        </div>
    </div>
</div>
<!--</div>-->
<script src="../static/layui/layui.js" charset="utf-8"></script>
<script>
    layui.use('laydate', function () {
        var laydate = layui.laydate;
        //日期时间选择器
        laydate.render({
            elem: '#test5'
            , type: 'datetime'
        });


    });
</script>

<script>
    <!-- 发布 -->
    layui.use(['layedit', 'form'], function () {
        var layedit = layui.layedit;
        var index = layedit.build('contents');
        var form = layui.form;
        form.verify({
            contents: function (value) {
                layedit.sync(index);
            }
        });
        form.on("submit(formSubmit)", function (data) {
            var grade = $("#pojo").val();
            var ass_id = $("#ass_id").val();
            if (grade>100 || grade<0||grade==''){
                alert("瞎打分,重来!")
                return false;
            }
            $.ajax({
                type: "post",
                url: "../teacher/corrcetsuccess",
                data: {
                    grade:grade,
                    ass_id:ass_id
                },
                success: function (data) {
                    if (data == "1") {
                        window.location.href = "/teacher/selectAssignment2"
                    }
                },
                error: function () {
                    alert("ajax error");
                }

            })
            return false;
        })
    });
</script>
</body>
</html>
